<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('采购单审核列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>采购单号：</label>
                            <input type="text" name="purId"/>
                        </li>
                        <li class="select-time">
                            <label>采购时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                        </li>
                        <li class="select-time">
                            <label>金额： </label>
                            <input type="text"  id="startMoney" placeholder="最小金额" name="params[beginMoney]"/>
                            <span>-</span>
                            <input type="text"   id="endMoney" placeholder="最大金额" name="params[endMoney]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="purchase:check:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('purchase:check:edit')}]];
    var prefix = ctx + "purchase/check";
    function numFormat(num) {
        var c = (num.toString().indexOf ('.') !== -1) ? num.toLocaleString() : num.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
        return c;
    }
    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            checkUrl: prefix + "/check/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "采购单信息",
            columns: [{
                checkbox: true
            },
                {
                    title: "序号",
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field: 'purId',
                    title: '采购单号',
                },
                {
                    field: 'purTime',
                    title: '采购时间'
                },
                {
                    field: 'total',
                    title: '金额',
                    formatter: function(value) {
                        var qianzhui ='￥';
                        if (value != null){
                            return qianzhui + numFormat(value);
                        }
                    }
                },
                {
                    field: 'sysUser.userName',
                    title: '操作人'
                },
                {
                    field: 'status',
                    title: '审核状态',
                    formatter: function(value) {
                        if (value==2){
                            return '审核中';
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editcheck(\'' + row.purId + '\')"><i class="fa fa-edit"></i>审核</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>